package com.multi.thread.chapter07.demo04;

public class Run {
	
	/**
	 * 线程组自动归属特性
	 */
	public static void main(String[] args) {
		System.out.println("A处线程：" + Thread.currentThread().getName() 
				+ ", 所属的线程组名为：" + Thread.currentThread().getThreadGroup().getName() 
				+ ", 有线程组数量：" + Thread.currentThread().getThreadGroup().activeGroupCount());
		
		new ThreadGroup("新的线程组");
		
		System.out.println("B处线程：" + Thread.currentThread().getName() 
				+ ", 所属的线程组名为：" + Thread.currentThread().getThreadGroup().getName() 
				+ ", 有线程组数量：" + Thread.currentThread().getThreadGroup().activeGroupCount());
		ThreadGroup[] threadgroup = new ThreadGroup[Thread.currentThread().getThreadGroup().activeGroupCount()];
		Thread.currentThread().getThreadGroup().enumerate(threadgroup);
		for (int i = 0; i < threadgroup.length; i++) {
			System.out.println("第一个线程组名称为：" + threadgroup[0].getName());
		}
	}

}
